namespace IQIGame.Onigao.GamePlay
{
    public partial class UIMapManager
    {
        private class UIQuestMapSymbol : UINormalMapSymbol
        {
            public override void Reset()
            {
                base.Reset();
                _msgDispatcher.Clear();
            }

            protected override void Draw()
            {
                if (_msgDispatcher is UIMsgDispatcher dispatcher)
                {
                    dispatcher.AddListener(MsgEventType.QuestAdd, RefreshSymbol);
                    dispatcher.AddListener(MsgEventType.QuestRemove, RefreshSymbol);
                }

                RefreshSymbol();
            }

            private void RefreshSymbol()
            {
                if (!data.isOfferingQuest)
                {
                    SetActive(false);
                    return;
                }
                base.Draw();
            }
        }
    }
}